import java.util.Stack;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 05 - 28
 * Time: 19:23
 */
public class Practice1 {
    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushA.length; i++) {
            stack.push(pushA[i]);
            while(!stack.isEmpty() && j < popA.length && stack.peek() == popA[j]) {
                stack.pop();
                j++;
            }
        }
        if(stack.isEmpty()) {
            return true;
        }
        return false;
    }
}
